package cn.ac.cintcm.dataconverge.researchsubject.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

import cn.ac.cintcm.dataconverge.researchsubject.domain.Subject;

import com.hs.core.utils.Tools;

public class SubjectUtil {
   
	public static Subject getObj(HttpServletRequest req,Subject obj){
		
		if(null == obj){
			obj = new Subject();
		}
		
		String subjectname = req.getParameter("subjectname");
		String subjectnameEn = req.getParameter("subjectnameEn");
		String study = req.getParameter("study");
		String content = req.getParameter("content");
		String abstractContent = req.getParameter("abstractContent");
		String theme = req.getParameter("theme");
		String applydate = req.getParameter("applydate");
		String permitdate = req.getParameter("permitdate");
		String startdate = req.getParameter("startdate");
		String enddate = req.getParameter("enddate");
		String checkdate= req.getParameter("checkdate");
		String endsubdate= req.getParameter("endsubdate");
		String applyfund= req.getParameter("applyfund");;
		String permitfund = req.getParameter("permitfund");
		String actualfund = req.getParameter("actualfund");
		String snumber= req.getParameter("snumber");
		String state= req.getParameter("state");  
		String projectorg = req.getParameter("projectorg");
		String projectname= req.getParameter("projectname");
		String formersubjectid= req.getParameter("formersubjectid");
		String memo1 = req.getParameter("memo1");
		String memo2 = req.getParameter("memo2");
		String memo3=  req.getParameter("memo3");  
		String belongyear=  req.getParameter("belongyear");
		String publicFlag = req.getParameter("ispublic");
		if(StringUtils.isNotBlank(publicFlag))
			obj.setPublicFlag(new Long(publicFlag));
		
		obj.setStudy(study);
		obj.setSubjectname(subjectname);
		obj.setSubjectnameEn(subjectnameEn);
		obj.setTheme(theme);
		obj.setContent(content);
		obj.setAbstractContent(abstractContent);
		if(StringUtils.isNotBlank(snumber))
		    obj.setSnumber(snumber);
		if(StringUtils.isNotBlank(actualfund))
		    obj.setActualfund(new Double(actualfund));
		if(StringUtils.isNotBlank(applyfund))
		    obj.setApplyfund(new Double(applyfund));
		if(StringUtils.isNotBlank(permitfund))
		    obj.setPermitfund(new Double(permitfund));
		if(StringUtils.isNotBlank(applydate))
			obj.setApplydate(Tools.getDateByYmdStr(applydate)); 
		if(StringUtils.isNotBlank(permitdate))
			obj.setPermitdate(Tools.getDateByYmdStr(permitdate));
		if(StringUtils.isNotBlank(startdate))
			obj.setStartdate(Tools.getDateByYmdStr(startdate));
		if(StringUtils.isNotBlank(enddate))
			obj.setEnddate(Tools.getDateByYmdStr(enddate));
		if(StringUtils.isNotBlank(checkdate))
			obj.setCheckdate(Tools.getDateByYmdStr(checkdate));
		if(StringUtils.isNotBlank(endsubdate))
			obj.setEndsubdate(Tools.getDateByYmdStr(endsubdate));
		obj.setMemo1(memo1);
		obj.setMemo2(memo2);
		obj.setMemo3(memo3);
		obj.setProjectname(projectname);
		obj.setProjectorg(projectorg);
		obj.setBelongyear(new Long(belongyear));
		obj.setState(state);
		 
		return obj;
	} 
}
